package com.huike.pullrefresh;

import android.os.Bundle;
import android.widget.ArrayAdapter;

import java.util.ArrayList;

import androidx.appcompat.app.AppCompatActivity;

/**
 * 下拉刷新demo1
 */
public class MainActivity extends AppCompatActivity {

    private ArrayList<String> list;
    private PullReFreshListView lv_main;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        list = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            list.add("a" + i);
        }
        final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, list);
        lv_main.setAdapter(adapter);

        lv_main.setOnRefreshListener(new PullReFreshListView.onRefreshListener() {
            @Override
            public void onRefresh() {

                for (int i = 0; i < 20; i++) {
                    list.add("B" + i);
                }
                adapter.notifyDataSetChanged();

                lv_main.ComplenerAnimation();

            }
        });


    }

    private void initView() {
        lv_main = (PullReFreshListView) findViewById(R.id.lv_main);
    }
}
